﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using Lawyer.Model;
namespace Lawyer.BLL
{
	/// <summary>
	/// ActivityInfo
	/// </summary>
	public partial class ActivityInfo
	{
		private readonly Lawyer.DAL.ActivityInfo dal=new Lawyer.DAL.ActivityInfo();
		public ActivityInfo()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ActivityID)
		{
			return dal.Exists(ActivityID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(Lawyer.Model.ActivityInfo model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Lawyer.Model.ActivityInfo model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string ActivityID)
		{
			
			return dal.Delete(ActivityID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string ActivityIDlist )
		{
			return dal.DeleteList(ActivityIDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Lawyer.Model.ActivityInfo GetModel(string ActivityID)
		{
			
			return dal.GetModel(ActivityID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public Lawyer.Model.ActivityInfo GetModelByCache(string ActivityID)
		{
			
			string CacheKey = "ActivityInfoModel-" + ActivityID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ActivityID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (Lawyer.Model.ActivityInfo)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Lawyer.Model.ActivityInfo> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Lawyer.Model.ActivityInfo> DataTableToList(DataTable dt)
		{
			List<Lawyer.Model.ActivityInfo> modelList = new List<Lawyer.Model.ActivityInfo>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Lawyer.Model.ActivityInfo model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Lawyer.Model.ActivityInfo();
					if(dt.Rows[n]["ActivityID"]!=null && dt.Rows[n]["ActivityID"].ToString()!="")
					{
					model.ActivityID=dt.Rows[n]["ActivityID"].ToString();
					}
					if(dt.Rows[n]["Type"]!=null && dt.Rows[n]["Type"].ToString()!="")
					{
					model.Type=dt.Rows[n]["Type"].ToString();
					}
					if(dt.Rows[n]["Title"]!=null && dt.Rows[n]["Title"].ToString()!="")
					{
					model.Title=dt.Rows[n]["Title"].ToString();
					}
					if(dt.Rows[n]["Detail"]!=null && dt.Rows[n]["Detail"].ToString()!="")
					{
					model.Detail=dt.Rows[n]["Detail"].ToString();
					}
					if(dt.Rows[n]["LawyerID"]!=null && dt.Rows[n]["LawyerID"].ToString()!="")
					{
					model.LawyerID=dt.Rows[n]["LawyerID"].ToString();
					}
					if(dt.Rows[n]["StartDate"]!=null && dt.Rows[n]["StartDate"].ToString()!="")
					{
						model.StartDate=DateTime.Parse(dt.Rows[n]["StartDate"].ToString());
					}
					if(dt.Rows[n]["EndDate"]!=null && dt.Rows[n]["EndDate"].ToString()!="")
					{
						model.EndDate=DateTime.Parse(dt.Rows[n]["EndDate"].ToString());
					}
					if(dt.Rows[n]["Fee"]!=null && dt.Rows[n]["Fee"].ToString()!="")
					{
						model.Fee=decimal.Parse(dt.Rows[n]["Fee"].ToString());
					}
					if(dt.Rows[n]["ArchiveID"]!=null && dt.Rows[n]["ArchiveID"].ToString()!="")
					{
					model.ArchiveID=dt.Rows[n]["ArchiveID"].ToString();
					}
					if(dt.Rows[n]["IsArchive"]!=null && dt.Rows[n]["IsArchive"].ToString()!="")
					{
						model.IsArchive=int.Parse(dt.Rows[n]["IsArchive"].ToString());
					}
					if(dt.Rows[n]["Status"]!=null && dt.Rows[n]["Status"].ToString()!="")
					{
						model.Status=int.Parse(dt.Rows[n]["Status"].ToString());
					}
					if(dt.Rows[n]["CreatedBy"]!=null && dt.Rows[n]["CreatedBy"].ToString()!="")
					{
					model.CreatedBy=dt.Rows[n]["CreatedBy"].ToString();
					}
					if(dt.Rows[n]["CreatedDate"]!=null && dt.Rows[n]["CreatedDate"].ToString()!="")
					{
						model.CreatedDate=DateTime.Parse(dt.Rows[n]["CreatedDate"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

